function my_sum(arr, n) result(sum_val)
    real, intent(in) :: arr(:)
    integer, intent(in) :: n
    real :: sum_val
    sum_val = 0.0
    do i = 1, n
      sum_val = sum_val + arr(i)
    end do
end function my_sum

